

***************************************************************
*******    Replication Code for The Human Cost of War   *******
**********   Ronan Fu, Weiwen Yin, and Enze Han  ************** 
***************************************************************

 
*** Preparation 

capture cd ""

use "Casualty_analysis.dta", clear


* Define control variables 
macro define covars "age gender college income religion party taiwanese position politics democracy nationalism mi active enemy ally"


*** ANOVA Results (Table A3-A5 in the Appendix)

anova score party_treatment##treat_size

pwcompare party_treatment, mcompare(tukey) effects

pwcompare treat_size, mcompare(tukey) effects


*** Treatment Effect of Different Warring Parties (Table 1 in the Maintext, Table A1 in the Appendix)
reg percentage ib2.group $covars if treat_size==1
estimates store A
reg percentage ib2.group $covars  if treat_size==2
estimates store B
reg percentage ib2.group $covars  if treat_size==3
estimates store C
reg percentage ib2.group $covars  
estimates store D

* Exporting Results to Word
*ssc install asdoc
asdoc reg percentage ib2.group $covars if treat_size==1,  nest replace stat(r2_a) label cnames(1,000) title(Treatment Effect of Warring Parties)
asdoc reg percentage ib2.group $covars  if treat_size==2, nest append stat(r2_a) label cnames(10,000) title(Treatment Effect of Warring Parties)
asdoc reg percentage ib2.group $covars  if treat_size==3, nest append stat(r2_a) label cnames(100,000) title(Treatment Effect of Warring Parties)
asdoc reg percentage ib2.group $covars                  , nest append stat(r2_a) label cnames(All) title(Treatment Effect of Warring Parties)

*** Coefficient Plots on Treatment Effects (Figure 1 in the Maintext)
coefplot A, drop($covars _cons) scheme(s1mono) baselevels bylabel(1,000 deaths) ///
|| B, drop($covars _cons)  baselevels bylabel(10,000 deaths)  ///
 || C, drop($covars _cons) baselevels bylabel(100,000 deaths) ///
  || D, drop($covars _cons) baselevels bylabel(All) ||, ///
 byopts(compact cols(1)) xline(0) ci(95) ///
 coeflabels(1.group = "US" 2.group = "Taiwan, China" 3.group = "PLA" 4.group = "Civilian") ///
 saving(coefplot-by-group, replace)
 graph export coefplot-by-group.jpg, replace


*** Predicted Support Percentages for Different Warring Party Treatments (Figure 2 in the Maintext)
*ssc install combomarginsplot

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=0) level(95) post saving(m1, replace)

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=1 treat_pla=0 treat_civil=0) level(95) post saving(m2, replace)

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=1 treat_civil=0) level(95) post saving(m3, replace)

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=1) level(95) post saving(m4, replace)

combomarginsplot m1 m3 m2 m4, labels("US" "PLA" "ROC" "Civilian") ///
scheme(s1mono) xtitle("") ytitle("Predicted Support Percentage, Full Sample") 
graph export predicted-support-all-95.jpg, replace  


*** Marginal Effect of Warring Party Treatments from Multiplicative Interaction Models (Figure 3 in the Maintext)

reg percentage i.treat_us##treat_size ///
               i.treat_pla##treat_size  ///
			   i.treat_civil##treat_size ///
			    $covars  // shoud use this one			  
margins, dydx(treat_us) at(treat_size=(1(1)3))
marginsplot, scheme(s1mono) plot1opts(lpattern(solid) lcolor(black)) ///
graphregion(color(white)) yline(0,lwidth(vthin) lcolor(black) lpattern(dash)) ///
ci1opts(fintensity(15) lpattern(dash_3dot) lcolor(black)) recast(scatter) ///
xtitle("Size Treatment") ytitle("Effect of US Treatment")  xlabel(1 "Small" 2 "Medium" 3 "Large") ///
title("") saving(us_size.gph, replace)

reg percentage i.treat_us##i.treat_size ///
               i.treat_pla##i.treat_size  ///
			   i.treat_civil##i.treat_size ///
			    $covars  // shoud use this one			  
margins, dydx(treat_pla) at(treat_size=(1(1)3))
marginsplot, scheme(s1mono) plot1opts(lpattern(solid) lcolor(black)) ///
graphregion(color(white)) yline(0,lwidth(vthin) lcolor(black) lpattern(dash)) ///
ci1opts(fintensity(15) lpattern(dash_3dot) lcolor(black)) recast(scatter) ///
xtitle("Size Treatment") ytitle("Effect of PLA Treatment")  xlabel(1 "Small" 2 "Medium" 3 "Large") ///
title("") saving(pla_size.gph, replace)

reg percentage i.treat_us##treat_size ///
               i.treat_pla##treat_size  ///
			   i.treat_civil##treat_size ///
			    $covars  // shoud use this one			  
margins, dydx(treat_civil) at(treat_size=(1(1)3)) 
marginsplot, scheme(s1mono) plot1opts(lpattern(solid) lcolor(black)) ///
graphregion(color(white)) yline(0,lwidth(vthin) lcolor(black) lpattern(dash)) ///
ci1opts(fintensity(15) lpattern(dash_3dot) lcolor(black)) recast(scatter) ///
xtitle("Size Treatment") ytitle("Effect of Civilian Treatment")  xlabel(1 "Small" 2 "Medium" 3 "Large") ///
title("") saving(civil_size.gph, replace)

gr combine us_size.gph pla_size.gph civil_size.gph, ///
scheme(s1mono) rows(1) ycommon
graph export margins_interactions.jpg, replace 
 
 
*** Estimating Heterogeneous Treatment Effects (Figure 4-5 in the Maintext) 

* full sample
reg support i.treat_us##c.mi    i.treat_pla##c.mi    i.treat_civil##c.mi ///
            i.treat_us##c.party i.treat_pla##c.party i.treat_civil##c.party ///
			i.treat_us##c.ally  i.treat_pla##c.ally  i.treat_civil##c.ally ///
			i.treat_us##c.enemy i.treat_pla##c.enemy i.treat_civil##c.enemy ///
			i.treat_us##c.nationalism i.treat_pla##c.nationalism i.treat_civil##c.nationalism $covars	

foreach i in party mi ally enemy nationalism {
sum `i', meanonly
local max = r(max)
margins, dydx(treat_us) at(`i'=(1(1)`max')) 	
marginsplot, plot1opts(lpattern(solid) lcolor(black)) ///
graphregion(color(white)) yline(0,lwidth(vthin) lcolor(black) lpattern(dash)) ///
ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot) lcolor(black)) recast(line) ///
 ytitle("") title("AME of US Treatment") level(95) saving(us_`i'.gph, replace)
}			

foreach i in party mi ally enemy nationalism {
sum `i', meanonly
local max = r(max)
margins, dydx(treat_pla) at(`i'=(1(1)`max')) 	
marginsplot, plot1opts(lpattern(solid) lcolor(black)) ///
graphregion(color(white)) yline(0,lwidth(vthin) lcolor(black) lpattern(dash)) ///
ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot) lcolor(black)) recast(line) ///
 ytitle("") title("AME of PLA Treatment") level(95) saving(pla_`i'.gph, replace)
}		

foreach i in party mi ally enemy nationalism {
sum `i', meanonly
local max = r(max)
margins, dydx(treat_civil) at(`i'=(1(1)`max')) 	
marginsplot, plot1opts(lpattern(solid) lcolor(black)) ///
graphregion(color(white)) yline(0,lwidth(vthin) lcolor(black) lpattern(dash)) ///
ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot) lcolor(black)) recast(line) ///
 ytitle("") title("AME of Civilian Treatment") level(95) saving(civil_`i'.gph, replace)
}	

** Figure 4 in the Maintext
gr combine us_party.gph pla_party.gph civil_party.gph  ///
           us_nationalism.gph pla_nationalism.gph civil_nationalism.gph  ///
		   us_mi.gph pla_mi.gph civil_mi.gph  ///
		   , graphregion(color(white)) col(3)  iscale(0.5) saving(party-nation-mi, replace)
graph export party-nation-mi.tif, replace 

** Figure 5 in the Maintext
gr combine us_ally.gph pla_ally.gph civil_ally.gph  ///
           us_enemy.gph pla_enemy.gph civil_enemy.gph  ///
		   , graphregion(color(white)) col(3)  iscale(0.5) saving(ally-enemy, replace)
graph export ally-enemy.tif, replace


 
 
 
**************************  Appendix  **************************



*** Predicted Support Percentages under Different Warring Party Treatments, Using Restricted Samples (Figure A1 in the Appendix)

* 1,000
reg percentage treat_roc1 treat_pla1 treat_civil1 $covars if treat_size==1
margins, atmeans at(treat_roc1=0 treat_pla1=0 treat_civil1=0) level(95) post saving(m5, replace)

reg percentage treat_roc1 treat_pla1 treat_civil1 $covars if treat_size==1
margins, atmeans at(treat_roc1=1 treat_pla1=0 treat_civil1=0) level(95) post saving(m6, replace)

reg percentage treat_roc1 treat_pla1 treat_civil1 $covars if treat_size==1
margins, atmeans at(treat_roc1=0 treat_pla1=1 treat_civil1=0) level(95) post saving(m7, replace)

reg percentage treat_roc1 treat_pla1 treat_civil1 $covars if treat_size==1
margins, atmeans at(treat_roc1=0 treat_pla1=0 treat_civil1=1) level(95) post saving(m8, replace)

combomarginsplot m5 m7 m6 m8, labels("US" "PLA" "ROC" "Civilian") ///
scheme(s1mono) xtitle("") ytitle("Predicted Support Percentage, 1000") 
graph export predicted-support-1000.jpg, replace

* 10,000 
reg percentage treat_roc2 treat_pla2 treat_civil2 $covars if treat_size==2
margins, atmeans at(treat_roc2=0 treat_pla2=0 treat_civil2=0) level(95) post saving(m1, replace)

reg percentage treat_roc2 treat_pla2 treat_civil2 $covars if treat_size==2
margins, atmeans at(treat_roc2=1 treat_pla2=0 treat_civil2=0) level(95) post saving(m2, replace)

reg percentage treat_roc2 treat_pla2 treat_civil2 $covars if treat_size==2
margins, atmeans at(treat_roc2=0 treat_pla2=1 treat_civil2=0) level(95) post saving(m3, replace)

reg percentage treat_roc2 treat_pla2 treat_civil2 $covars if treat_size==2
margins, atmeans at(treat_roc2=0 treat_pla2=0 treat_civil2=1) level(95) post saving(m4, replace)

combomarginsplot m1 m3 m2 m4, labels("US" "PLA" "ROC" "Civilian") ///
scheme(s1mono) xtitle("") ytitle("Predicted Support Percentage, 10000") 
graph export predicted-support-10000.jpg, replace


* 100,000
reg percentage treat_roc3 treat_pla3 treat_civil3 $covars if treat_size==3
margins, atmeans at(treat_roc3=0 treat_pla3=0 treat_civil3=0) level(95) post saving(m9, replace)

reg percentage treat_roc3 treat_pla3 treat_civil3 $covars if treat_size==3
margins, atmeans at(treat_roc3=1 treat_pla3=0 treat_civil3=0) level(95) post saving(m10, replace)

reg percentage treat_roc3 treat_pla3 treat_civil3 $covars if treat_size==3
margins, atmeans at(treat_roc3=0 treat_pla3=1 treat_civil3=0) level(95) post saving(m11, replace)

reg percentage treat_roc3 treat_pla3 treat_civil3 $covars if treat_size==3
margins, atmeans at(treat_roc3=0 treat_pla3=0 treat_civil3=1) level(95) post saving(m12, replace)

combomarginsplot m5 m7 m6 m8, labels("US" "PLA" "ROC" "Civilian") ///
scheme(s1mono) xtitle("") ytitle("Predicted Support Percentage, 100000") 
graph export predicted-support-100000.jpg, replace



*** Treatment Effect of Different Warring Parties, Using the Original Measure of Support Score 

** Table A2 in the Appendix
reg support treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=0) level(95) post saving(m1, replace)

reg support treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=1 treat_pla=0 treat_civil=0) level(95) post saving(m2, replace)

reg support treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=1 treat_civil=0) level(95) post saving(m3, replace)

reg support treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=1) level(95) post saving(m4, replace)

asdoc reg support ib2.group $covars if treat_size==1, nest replace stat(r2_a) label cnames(US) title(Treatment Effect of Warring Parties, Original DV)
asdoc reg support ib2.group $covars  if treat_size==2, nest append  stat(r2_a) label cnames(ROC) title(Treatment Effect of Warring Parties, Original DV)
asdoc reg support ib2.group $covars  if treat_size==3, nest append  stat(r2_a) label cnames(PLA) title(Treatment Effect of Warring Parties, Original DV)
asdoc reg support ib2.group $covars,             nest append  stat(r2_a) label cnames(All) title(Treatment Effect of Warring Parties, Original DV)

** Figure A2 in the Appendix
combomarginsplot m1 m3 m2 m4, labels("US" "PLA" "ROC" "Civilian") ///
scheme(s1mono) xtitle("") ytitle("Predicted Support Score, Full Sample") 
graph export predicted-orginal-all-95.jpg, replace   



*** Estimating the Marginal Effects of Size Treatments Using a Framework of Multiplicative Interaction Model (Figure A3 in the Appendix)
gen medium=0
replace medium=1 if treat_size==2

gen large=0
replace large=1 if treat_size==3

reg percentage i.treat_us##i.medium i.treat_us##i.large ///
               i.treat_pla##i.medium i.treat_pla##i.large ///
			   i.treat_civil##i.medium i.treat_civil##i.large ///
			    $covars				
margins, dydx(medium) at(treat_us=(0(1)1)) saving(m1, replace)	
margins, dydx(large) at(treat_us=(0(1)1)) saving(m2, replace)	
combomarginsplot m1 m2, offset(.1) xtitle("Effect of Size Treatment") title("") scheme(s1mono)	recast(scatter) legend(order(1 "AME of Meiudm Size" 2 "AME of Large Size")  size(small)) horizontal saving(size_us.gph, replace)

reg percentage i.treat_us##i.medium i.treat_us##i.large ///
               i.treat_pla##i.medium i.treat_pla##i.large ///
			   i.treat_civil##i.medium i.treat_civil##i.large ///
			    $covars
margins, dydx(medium) at(treat_pla=(0(1)1)) saving(m1, replace)	
margins, dydx(large) at(treat_pla=(0(1)1)) saving(m2, replace)	
combomarginsplot m1 m2, offset(.1) xtitle("Effect of Size Treatment") title("") scheme(s1mono)	recast(scatter) legend(order(1 "AME of Meiudm Size" 2 "AME of Large Size")  size(small)) horizontal saving(size_pla.gph, replace)

reg percentage i.treat_us##i.medium i.treat_us##i.large ///
               i.treat_pla##i.medium i.treat_pla##i.large ///
			   i.treat_civil##i.medium i.treat_civil##i.large ///
			    $covars
margins, dydx(medium) at(treat_civil=(0(1)1)) saving(m1, replace)	
margins, dydx(large) at(treat_civil=(0(1)1)) saving(m2, replace)	
combomarginsplot m1 m2, offset(.1) xtitle("Effect of Size Treatment") title("") scheme(s1mono)	recast(scatter) legend(order(1 "AME of Meiudm Size" 2 "AME of Large Size")  size(small)) horizontal saving(size_civil.gph, replace)

gr combine size_us.gph size_pla.gph size_civil.gph, ///
scheme(s1mono) rows(3) xcommon
graph export size_interactions.jpg, replace 



*** Predicted War Support for Chinese Civilian Treatment (Section 7 in the Appendix)

reg percentage both_innocent  if treat_civil==1
gen sample=e(sample)
predict p_percentage if sample==1


** Table A6 in the Appendix
reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=0) level(95) post saving(m1, replace)

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=1 treat_pla=0 treat_civil=0) level(95) post saving(m2, replace)

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=1 treat_civil=0) level(95) post saving(m3, replace)

reg p_percentage treat_roc treat_pla treat_civil $covars if sample==1
predict plot_percentage if sample==1
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=1) level(95) post saving(m4, replace)

* making tables
asdoc reg percentage both_innocent if treat_civil==1, nest replace stat(r2_a) label cnames(First-stage) title(Addressing Tactical Concerns for Civilian Casualties)
asdoc reg percentage both_innocent taiwan_innocent china_innocent if treat_civil==1, nest append stat(r2_a) label cnames(First-stage alternative) title(Addressing Tactical Concerns for Civilian Casualties)
asdoc reg p_percentage treat_roc treat_pla treat_civil $covars if sample==1,             nest append  stat(r2_a) label cnames(Second-stage) title(Addressing Tactical Concerns for Civilian Casualties)

** Figure A4 in the Appendix
combomarginsplot m1 m3 m2 m4, labels("US" "PLA" "ROC" "Civilian") ///
scheme(s1mono) xtitle("") ytitle("Predicted Support Percentage, Full Sample") 
graph export predicted-support-all-predictedy4.jpg, replace   // overlap

** Summary Statistics for the Dependent Variables (DV) (Table A7 in the Appendix)
sum percentage p_percentage plot_percentage if sample==1


** Alternative First-stage Model (Figure A5 in the Appendix)
reg percentage both_innocent china_innocent taiwan_innocent if treat_civil==1
gen sample2=e(sample)
predict p_percentage2 if sample2==1

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=0) level(95) post saving(m1, replace)

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=1 treat_pla=0 treat_civil=0) level(95) post saving(m2, replace)

reg percentage treat_roc treat_pla treat_civil $covars 
margins, atmeans at(treat_roc=0 treat_pla=1 treat_civil=0) level(95) post saving(m3, replace)

reg p_percentage2 treat_roc treat_pla treat_civil $covars  if sample2==1
margins, atmeans at(treat_roc=0 treat_pla=0 treat_civil=1) level(95) post saving(m4, replace)

combomarginsplot m1 m3 m2 m4, labels("US" "PLA" "ROC" "Civilian")  ///
scheme(s1mono) xtitle("") ytitle("Predicted Support Percentage, Full Sample") 
graph export predicted-support-all-predictedy4-2.jpg, replace   















